package com.zr.subclass.mapper;

import com.zr.subclass.pojo.SubClassSelectVo;
import com.zr.subclass.pojo.SubClassVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by Liyiding on 2019/9/22.
 */
@Mapper
public interface SubClassMapper {
    @Select("select * from subclass where name=#{name}")
    List<SubClassVo> queryByName(String name);

    @Select("select * from subclass where code=#{code}")
    List<SubClassVo> queryByCode(String code);

    @Insert("insert into subclass (name,code,remark,status,createName,createTime,updateName,updateTime) values" +
            "(#{name},#{code},#{remark},#{status},#{createName},#{createTime},#{updateName},#{updateTime})")
    void add(SubClassVo subClassVo);

    @Update("update subclass set status=#{status},updateName=#{updateName},updateTime=#{updateTime} where id=#{id}")
    void updateStatus(SubClassVo subClassVo1);

    @Update("update subclass set name=#{name},remark=#{remark},status=#{status},updateName=#{updateName},updateTime=#{updateTime},version=#{version}+1 where id=#{id} and version =#{version}")
    int update(SubClassVo subClassVo1);

    int queryCount(SubClassSelectVo subClassSelectVo);

    List<SubClassVo> queryData(SubClassSelectVo subClassSelectVo);

    @Select("select * from subclass where id=#{id}")
    SubClassVo queryById(Integer id);
}
